package cn.xiongxf.feign;

import cn.xiongxf.domain.Login;
import cn.xiongxf.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component  // 交给Spring容器管理
public class LoginFeignClientFallbackFactory implements FallbackFactory<LoginFeignClient> {
    @Override
    public LoginFeignClient create(Throwable throwable) {
        // 打印接口错误，方便查找错误
        throwable.printStackTrace();
        return new LoginFeignClient() {
            @Override
            public JsonResult save(Login login) {

                return JsonResult.error("触发熔断,当前服务不可用,请稍后再试!");
            }
        };
    }
}
